package com.netease.framework.a;

import com.netease.c.j;
import com.netease.e.b;
import com.netease.pris.a.i;
import com.netease.pris.a.t;
import com.netease.pris.a.u;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;

public class a
{
  static SchemeRegistry a;
  static int h = 0;
  private static final boolean i = false;
  private static final int j = -3;
  private static final int k = 2;
  private static final int l = 60000;
  private static final int m = 2000;
  private static final int n = 8000;
  private static final int o = 4;
  private static int r = 1;
  long b;
  j c;
  HashMap d;
  LinkedList e;
  HttpClient f;
  boolean g = false;
  private int p = 4;
  private int q;

  static
  {
    a = new SchemeRegistry();
    a.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    a.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    h = 0;
  }

  public a()
  {
    this(4);
  }

  public a(int paramInt)
  {
    this(4, 5);
  }

  public a(int paramInt1, int paramInt2)
  {
    this.p = paramInt1;
    this.q = paramInt2;
    this.c = new j();
    this.d = new HashMap();
    this.e = new LinkedList();
    while (i1 < this.p)
    {
      d locald = new d(this);
      locald.setPriority(this.q);
      this.e.add(locald);
      locald.start();
      i1++;
    }
  }

  /** @deprecated */
  public static int b()
  {
    monitorenter;
    try
    {
      int i1 = h;
      h = i1 + 1;
      monitorexit;
      return i1;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  private HttpClient c()
  {
    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(localBasicHttpParams, 20000);
    HttpConnectionParams.setSoTimeout(localBasicHttpParams, 60000);
    HttpConnectionParams.setSocketBufferSize(localBasicHttpParams, 8192);
    HttpProtocolParams.setUseExpectContinue(localBasicHttpParams, false);
    DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, a), localBasicHttpParams);
    localDefaultHttpClient.getParams().setParameter("http.protocol.handle-redirects", Boolean.valueOf(true));
    com.netease.e.d locald = b.a(com.netease.b.a.d.h().a()).c();
    if ((locald != null) && (!i.e(locald.d)))
    {
      HttpHost localHttpHost = new HttpHost(locald.d, locald.c);
      localDefaultHttpClient.getParams().setParameter("http.route.default-proxy", localHttpHost);
    }
    return localDefaultHttpClient;
  }

  private boolean c(m paramm)
  {
    if ((this.g) || (paramm.u()));
    for (int i1 = 1; ; i1 = 0)
      return i1;
  }

  private boolean d()
  {
    Iterator localIterator = this.e.iterator();
    do
      if (!localIterator.hasNext())
        break;
    while (((d)localIterator.next()).c());
    for (int i1 = 1; ; i1 = 0)
      return i1;
  }

  private void e()
  {
    if ((this.e.size() >= this.p) && (this.e.size() < this.p + r) && (!d()))
    {
      t localt = u.c(com.netease.b.a.d.h().a());
      if ((localt != t.d) && (localt != t.c))
        break label79;
      if (System.currentTimeMillis() - this.b >= 8000L)
        break label94;
    }
    while (true)
    {
      return;
      label79: if (System.currentTimeMillis() - this.b < 2000L)
        continue;
      label94: g localg = new g(this);
      synchronized (this.e)
      {
        this.e.add(localg);
        localg.start();
      }
    }
  }

  public Vector a(m paramm)
  {
    if ((paramm != null) && (paramm.e()))
      synchronized (this.d)
      {
        localVector = (Vector)this.d.remove(paramm.b() + paramm.l());
      }
    Vector localVector = null;
    return localVector;
  }

  public void a()
  {
    this.g = true;
    if (this.f != null)
    {
      this.f.getConnectionManager().shutdown();
      this.f = null;
    }
    this.e.clear();
    this.d.clear();
    this.c.f();
    Iterator localIterator = this.e.iterator();
    while (localIterator.hasNext())
    {
      d locald = (d)localIterator.next();
      try
      {
        locald.interrupt();
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
      }
    }
    this.c.e();
  }

  public void a(int paramInt1, int paramInt2)
  {
    this.c.a(paramInt1, paramInt2);
    if ((paramInt2 & 0xFF) == 4)
      e();
  }

  public void a(m paramm, int paramInt)
  {
    this.c.a(paramm, paramInt);
    if ((paramInt & 0xFF) == 4)
      e();
  }

  public void a(Class paramClass)
  {
    Vector localVector = this.c.a(paramClass);
    if ((localVector != null) && (localVector.size() > 0))
    {
      Iterator localIterator = localVector.iterator();
      while (localIterator.hasNext())
        ((m)localIterator.next()).r();
    }
  }

  protected void a(Vector paramVector)
  {
    if ((paramVector != null) && (paramVector.size() > 0))
    {
      Iterator localIterator = paramVector.iterator();
      while (localIterator.hasNext())
      {
        m localm = (m)localIterator.next();
        this.c.a(localm, localm.f());
      }
    }
  }

  public void b(m paramm)
  {
    a(paramm, 1);
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.framework.a.a
 * JD-Core Version:    0.6.0
 */